from Base import Asset

from DataFeeder.QueryQuote import query_futures_quote
from DataFeeder.QueryCurrency import query_futures_currency
from DataFeeder.QueryOthers import query_point_value

class Futures(Asset):

	def npv_in_local_currency(self, ref_time, quote_type):
	
		return query_futures_quote(ref_time, self.ticker(), quote_type)*self.point_value()
		
	@staticmethod
	def type_name():
		return "FUTURES"
		
	def __init__(self, ticker):
		self.futures_ticker = ticker
		self.futures_point_value = query_point_value(ticker)
		self.futures_currency = query_futures_currency(ticker)
		
	def ticker(self):
		return self.futures_ticker
					
	def currency(self):
		return self.futures_currency
		
	def point_value(self):
		return self.futures_point_value
		
	def __hash__(self):
		return hash(self.futures_ticker)
		
	def __eq__(self, other):
		return other and self.ticker() == other.ticker()